package com.luxury.adpter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.luxury.R;
import com.luxury.bean.Type12BeanEnd;
import com.luxury.helper.RecyclerViewAdapterHelper;

import java.util.List;

/**
 * Created by Administrator on 2016/12/19.
 */

public class Type12EndRecyclerAdapter extends RecyclerViewAdapterHelper<Type12BeanEnd.ProductType1Bean> {
//    private
    public Type12EndRecyclerAdapter(Context mContext, List<Type12BeanEnd.ProductType1Bean> list) {
        super(mContext, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateMyViewHolder(ViewGroup parent, int viewType) {
        View view=mInflater.inflate(R.layout.item_type12recyclerview,parent,false);
        return new ViewHolderItem(view);
    }
    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ViewHolderItem){
            //得到产品名字
            String name = mList.get(position).getName();
            //得到产品图片地址
            String picUrl = "http://pic11.secooimg.com/product/300/300/"+mList.get(position).getPicUrl();
            //得到产品价格
            int secooPrice = mList.get(position).getSecooPrice();
            Glide.with(mContext).load(picUrl).into( ((ViewHolderItem) holder).iv_itemType12rv);
            ((ViewHolderItem) holder).tv_name_itemType12rv.setText(name);
            ((ViewHolderItem) holder).tv_price_itemType12rv.setText("￥"+secooPrice);
        }

    }
    class ViewHolderItem extends RecyclerView.ViewHolder {
        private ImageView iv_itemType12rv;
        private TextView tv_name_itemType12rv,tv_price_itemType12rv;

        public ViewHolderItem(View itemView) {
            super(itemView);
            iv_itemType12rv= (ImageView) itemView.findViewById(R.id.iv_itemType12rv);
            tv_name_itemType12rv= (TextView) itemView.findViewById(R.id.tv_name_itemType12rv);
            tv_price_itemType12rv= (TextView) itemView.findViewById(R.id.tv_price_itemType12rv);
        }
    }
}
